package com.cs.club.domain.service.impl;

import com.cs.club.common.entity.ErrorCode;
import com.cs.club.common.utlis.ThrowUtils;
import com.cs.club.domain.bos.ClubAssetsBO;
import com.cs.club.domain.service.ClubAssetsDomainService;
import com.cs.club.infra.basic.entity.ClubAssets;
import com.cs.club.infra.basic.service.ClubAssetsService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class ClubAssetsDomainServiceImpl implements ClubAssetsDomainService {

    @Resource
    private ClubAssetsService clubAssetsService;

    @Override
    public Boolean addClubAssets(ClubAssetsBO clubAssetsBO) {
        // 参数校验
        ThrowUtils.throwIf(clubAssetsBO.getAssetsName() == null, ErrorCode.PARAMS_ERROR,"资产名称呢？");
        ClubAssets clubAssets = new ClubAssets();
        BeanUtils.copyProperties(clubAssetsBO, clubAssets);
        return clubAssetsService.addClubAssets(clubAssets);
    }

    @Override
    public Boolean deleteClubAssets(ClubAssetsBO clubAssetsBO) {
        ClubAssets clubAssets = new ClubAssets();
        BeanUtils.copyProperties(clubAssetsBO, clubAssets);
        return clubAssetsService.deleteClubAssets(clubAssets);
    }

    @Override
    public Boolean updateClubAssets(ClubAssetsBO clubAssetsBO) {
        ClubAssets clubAssets = new ClubAssets();
        BeanUtils.copyProperties(clubAssetsBO, clubAssets);
        return clubAssetsService.updateClubAssets(clubAssets);
    }
}
